/*
 * 版权所有 Amor. 保留所有权利。
 * 根据 MIT 许可证条款分发。
 *
 * 作者： amor
 */
#ifndef ANT_CONTROL_LOOK_H
#define ANT_CONTROL_LOOK_H

#include <ControlLook.h>

#include "HaikuControlLook.h"

class BBitmap;
class BControl;
class BGradientLinear;
class BView;

namespace BPrivate {

using BPrivate::HaikuControlLook;

class AntControlLook : public HaikuControlLook {
 public:
  AntControlLook();
  virtual ~AntControlLook();

  virtual void DrawButtonFrame(BView* view, BRect& rect,
                               const BRect& updateRect, const rgb_color& base,
                               const rgb_color& background, uint32 flags = 0,
                               uint32 borders = B_ALL_BORDERS);
  virtual void DrawButtonFrame(BView* view, BRect& rect,
                               const BRect& updateRect, float radius,
                               const rgb_color& base,
                               const rgb_color& background, uint32 flags = 0,
                               uint32 borders = B_ALL_BORDERS);
  virtual void DrawButtonFrame(BView* view, BRect& rect,
                               const BRect& updateRect, float leftTopRadius,
                               float rightTopRadius, float leftBottomRadius,
                               float rightBottomRadius, const rgb_color& base,
                               const rgb_color& background, uint32 flags = 0,
                               uint32 borders = B_ALL_BORDERS);

  virtual void DrawButtonBackground(BView* view, BRect& rect,
                                    const BRect& updateRect,
                                    const rgb_color& base, uint32 flags = 0,
                                    uint32 borders = B_ALL_BORDERS,
                                    orientation orientation = B_HORIZONTAL);
  virtual void DrawButtonBackground(BView* view, BRect& rect,
                                    const BRect& updateRect, float radius,
                                    const rgb_color& base, uint32 flags = 0,
                                    uint32 borders = B_ALL_BORDERS,
                                    orientation orientation = B_HORIZONTAL);
  virtual void DrawButtonBackground(
      BView* view, BRect& rect, const BRect& updateRect, float leftTopRadius,
      float rightTopRadius, float leftBottomRadius, float rightBottomRadius,
      const rgb_color& base, uint32 flags = 0, uint32 borders = B_ALL_BORDERS,
      orientation orientation = B_HORIZONTAL);

  virtual void DrawMenuBarBackground(BView* view, BRect& rect,
                                     const BRect& updateRect,
                                     const rgb_color& base, uint32 flags,
                                     uint32 borders = B_ALL_BORDERS);
  virtual void DrawMenuItemBackground(BView* view, BRect& rect,
                                      const BRect& updateRect,
                                      const rgb_color& base, uint32 flags = 0,
                                      uint32 borders = B_ALL_BORDERS);
  virtual void DrawMenuFieldFrame(BView* view, BRect& rect,
                                  const BRect& updateRect,
                                  const rgb_color& base,
                                  const rgb_color& background, uint32 flags,
                                  uint32 borders);
  virtual void DrawMenuFieldFrame(BView* view, BRect& rect,
                                  const BRect& updateRect, float radius,
                                  const rgb_color& base,
                                  const rgb_color& background, uint32 flags,
                                  uint32 borders);
  virtual void DrawMenuFieldFrame(BView* view, BRect& rect,
                                  const BRect& updateRect, float leftTopRadius,
                                  float rightTopRadius, float leftBottomRadius,
                                  float rightBottomRadius,
                                  const rgb_color& base,
                                  const rgb_color& background, uint32 flags,
                                  uint32 borders);

  virtual void DrawMenuFieldBackground(BView* view, BRect& rect,
                                       const BRect& updateRect,
                                       const rgb_color& base, uint32 flags,
                                       uint32 borders);
  virtual void DrawMenuFieldBackground(BView* view, BRect& rect,
                                       const BRect& updateRect, float radius,
                                       const rgb_color& base, uint32 flags,
                                       uint32 borders);
  virtual void DrawMenuFieldBackground(
      BView* view, BRect& rect, const BRect& updateRect, float leftTopRadius,
      float rightTopRadius, float leftBottomRadius, float rightBottomRadius,
      const rgb_color& base, uint32 flags, uint32 borders);

  virtual void DrawMenuBackground(BView* view, BRect& rect,
                                  const BRect& updateRect,
                                  const rgb_color& base, uint32 flags = 0,
                                  uint32 borders = B_ALL_BORDERS);

  virtual void DrawScrollBarBorder(BView* view, BRect rect,
                                   const BRect& updateRect,
                                   const rgb_color& base, uint32 flags,
                                   orientation orientation);
  virtual void DrawScrollBarButton(BView* view, BRect rect,
                                   const BRect& updateRect,
                                   const rgb_color& base, uint32 flags,
                                   int32 direction, orientation orientation,
                                   bool down = false);
  virtual void DrawScrollBarBackground(BView* view, BRect& rect1, BRect& rect2,
                                       const BRect& updateRect,
                                       const rgb_color& base, uint32 flags,
                                       orientation orientation);
  virtual void DrawScrollBarBackground(BView* view, BRect& rect,
                                       const BRect& updateRect,
                                       const rgb_color& base, uint32 flags,
                                       orientation orientation);
  virtual void DrawScrollBarThumb(BView* view, BRect& rect,
                                  const BRect& updateRect,
                                  const rgb_color& base, uint32 flags,
                                  orientation orientation);

  virtual void DrawScrollViewFrame(BView* view, BRect& rect,
                                   const BRect& updateRect,
                                   border_style borderStyle, uint32 flags = 0,
                                   uint32 borders = B_ALL_BORDERS);

  virtual rgb_color SliderBarColor(const rgb_color& base);

  virtual void DrawSliderBar(BView* view, BRect rect, const BRect& updateRect,
                             const rgb_color& base, rgb_color leftFillColor,
                             rgb_color rightFillColor, uint32 flags,
                             orientation orientation);
  virtual void DrawSliderBar(BView* view, BRect rect, const BRect& updateRect,
                             const rgb_color& base, rgb_color fillColor,
                             uint32 flags, orientation orientation);

  virtual void DrawSliderThumb(BView* view, BRect& rect,
                               const BRect& updateRect, const rgb_color& base,
                               uint32 flags, orientation orientation);

  virtual void DrawActiveTab(BView* view, BRect& rect, const BRect& updateRect,
                             const rgb_color& base, uint32 flags = 0,
                             uint32 borders = B_ALL_BORDERS,
                             border_style borderStyle = B_FANCY_BORDER,
                             uint32 side = B_TOP_BORDER);

  virtual void DrawInactiveTab(BView* view, BRect& rect,
                               const BRect& updateRect, const rgb_color& base,
                               uint32 flags = 0, uint32 borders = B_ALL_BORDERS,
                               uint32 side = B_TOP_BORDER, int32 index = 0,
                               int32 selected = -1, int32 first = 0,
                               int32 last = 0);

  virtual void DrawSplitter(BView* view, BRect& rect, const BRect& updateRect,
                            const rgb_color& base, orientation orientation,
                            uint32 flags = 0, uint32 borders = B_ALL_BORDERS);

  virtual void DrawBorder(BView* view, BRect& rect, const BRect& updateRect,
                          const rgb_color& base, border_style borderStyle,
                          uint32 flags = 0, uint32 borders = B_ALL_BORDERS);

  virtual void DrawRaisedBorder(BView* view, BRect& rect,
                                const BRect& updateRect, const rgb_color& base,
                                uint32 flags = 0,
                                uint32 borders = B_ALL_BORDERS);

  virtual void DrawTextControlBorder(BView* view, BRect& rect,
                                     const BRect& updateRect,
                                     const rgb_color& base, uint32 flags = 0,
                                     uint32 borders = B_ALL_BORDERS);

  virtual void DrawGroupFrame(BView* view, BRect& rect, const BRect& updateRect,
                              const rgb_color& base,
                              uint32 borders = B_ALL_BORDERS);

  virtual void DrawButtonWithPopUpBackground(
      BView* view, BRect& rect, const BRect& updateRect, const rgb_color& base,
      uint32 flags = 0, uint32 borders = B_ALL_BORDERS,
      orientation orientation = B_HORIZONTAL);
  virtual void DrawButtonWithPopUpBackground(
      BView* view, BRect& rect, const BRect& updateRect, float radius,
      const rgb_color& base, uint32 flags = 0, uint32 borders = B_ALL_BORDERS,
      orientation orientation = B_HORIZONTAL);
  virtual void DrawButtonWithPopUpBackground(
      BView* view, BRect& rect, const BRect& updateRect, float leftTopRadius,
      float rightTopRadius, float leftBottomRadius, float rightBottomRadius,
      const rgb_color& base, uint32 flags = 0, uint32 borders = B_ALL_BORDERS,
      orientation orientation = B_HORIZONTAL);

  // Ant Design 5 特定按钮绘制方法
  void DrawPrimaryButton(BView* view, BRect& rect,
                        const BRect& updateRect,
                        const rgb_color& base,
                        uint32 flags = 0,
                        const char* text = NULL,
                        const BBitmap* icon = NULL);
  
  void DrawSecondaryButton(BView* view, BRect& rect,
                           const BRect& updateRect,
                           const rgb_color& base,
                           uint32 flags = 0,
                           const char* text = NULL,
                           const BBitmap* icon = NULL);

 private:
  // Border drawing
  void _DrawButtonFrame(BView* view, BRect& rect, const BRect& updateRect,
                        float leftTopRadius, float rightTopRadius,
                        float leftBottomRadius, float rightBottomRadius,
                        const rgb_color& base, const rgb_color& background,
                        float contrast = 1.0f, float brightness = 1.0f,
                        uint32 flags = 0, uint32 borders = B_ALL_BORDERS);

  void _DrawOuterResessedFrame(BView* view, BRect& rect, const rgb_color& base,
                               float contrast = 1.0f, float brightness = 1.0f,
                               uint32 flags = 0,
                               uint32 borders = B_ALL_BORDERS);

  // Button background
  void _DrawButtonBackground(BView* view, BRect& rect, const BRect& updateRect,
                             float leftTopRadius, float rightTopRadius,
                             float leftBottomRadius, float rightBottomRadius,
                             const rgb_color& base, bool popupIndicator = false,
                             uint32 flags = 0, uint32 borders = B_ALL_BORDERS,
                             orientation orientation = B_HORIZONTAL);

  void _DrawNonFlatButtonBackground(
      BView* view, BRect& rect, const BRect& updateRect, float leftTopRadius,
      float rightTopRadius, float leftBottomRadius, float rightBottomRadius,
      const rgb_color& base, bool popupIndicator = false, uint32 flags = 0,
      uint32 borders = B_ALL_BORDERS, orientation orientation = B_HORIZONTAL);

  void _DrawPopUpMarker(BView* view, const BRect& rect, const rgb_color& base,
                        uint32 flags);

  // Menus
  void _DrawMenuFieldBackgroundOutside(
      BView* view, BRect& rect, const BRect& updateRect, float leftTopRadius,
      float rightTopRadius, float leftBottomRadius, float rightBottomRadius,
      const rgb_color& base, bool popupIndicator = false, uint32 flags = 0,
      uint32 borders = B_ALL_BORDERS);

  void _DrawMenuFieldBackgroundInside(
      BView* view, BRect& rect, const BRect& updateRect, float leftTopRadius,
      float rightTopRadius, float leftBottomRadius, float rightBottomRadius,
      const rgb_color& base, bool popupIndicator = false, uint32 flags = 0,
      uint32 borders = B_ALL_BORDERS);

  // Checkboxes

  // Colors
  rgb_color _EdgeLightColor(const rgb_color& base, float contrast,
                            float brightness, uint32 flags);

  rgb_color _EdgeShadowColor(const rgb_color& base, float contrast,
                             float brightness, uint32 flags);

  rgb_color _BevelLightColor(const rgb_color& base, uint32 flags);

  rgb_color _BevelShadowColor(const rgb_color& base, uint32 flags);

  // Gradients
  void _MakeGradient(BGradientLinear& gradient, const BRect& rect,
                     const rgb_color& base, float topTint, float bottomTint,
                     orientation orientation = B_HORIZONTAL) const;

  void _MakeGlossyGradient(BGradientLinear& gradient, const BRect& rect,
                           const rgb_color& base, float topTint,
                           float bottomTint,
                           orientation orientation = B_HORIZONTAL) const;

  void _MakeButtonGradient(BGradientLinear& gradient, BRect& rect,
                           const rgb_color& base, uint32 flags,
                           orientation orientation = B_HORIZONTAL) const;
};

}  // namespace BPrivate

#endif  // ANT_CONTROL_LOOK_H